package com.example.opengldemo._07_texture;

import android.opengl.GLES30;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.opengldemo.R;
import com.example.opengldemo.util.MatrixState;

public class MyDemoActivity extends AppCompatActivity {
    SurfaceView surfaceView  ;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_surface);
        surfaceView = findViewById(R.id.surface);
        final GLRenderer renderer = new GLRenderer(surfaceView) ;
        renderer.start();
        surfaceView.getHolder().addCallback(new SurfaceHolder.Callback2() {
            @Override
            public void surfaceRedrawNeeded(SurfaceHolder holder) {
                Log.e("surfaceView" , "surfaceRedrawNeeded") ;
            }

            @Override
            public void surfaceCreated(SurfaceHolder holder) {
                Log.e("surfaceView" , "surfaceCreated") ;
            }

            @Override
            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
                Log.e("surfaceView" , "surfaceChanged") ;
                renderer.change(width , height);
                renderer.render(holder.getSurface(), width , height);
            }

            @Override
            public void surfaceDestroyed(SurfaceHolder holder) {
                Log.e("surfaceView" , "surfaceDestroyed") ;
            }
        });
    }
}
